home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 2 / adb / a-taside < prev    next >
Text File  |  1996-02-12  |  5KB  |  121 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --              A D A . T A S K _ I D E N T I F I C A T I O N               --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.9 $                              --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc.     --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with System.Address_Image;
  37. with System.Tasking.Abortion;
  38. with System.Tasking.Stages;
  39. with System.Tasking.Rendezvous;
  40.  
  41. with Unchecked_Conversion;
  42.  
  43. package body Ada.Task_Identification is
  44.  
  45.    ---------
  46.    -- "=" --
  47.    ---------
  48.  
  49.    function  "=" (Left, Right : Task_Id) return Boolean is
  50.    begin
  51.       return System.Tasking."=" (Convert_Ids (Left), Convert_Ids (Right));
  52.    end "=";
  53.  
  54.    -----------------
  55.    -- Abort_Task --
  56.    ----------------
  57.  
  58.    procedure Abort_Task (T : in out Task_Id) is
  59.    begin
  60.       if T = Null_Task_Id then
  61.          raise Program_Error;
  62.       else
  63.          System.Tasking.Abortion.Abort_Tasks
  64.            (System.Tasking.Task_List'(1 => Convert_Ids (T)));
  65.       end if;
  66.    end Abort_Task;
  67.  
  68.    ------------------
  69.    -- Current_Task --
  70.    ------------------
  71.  
  72.    function Current_Task return Task_Id is
  73.    begin
  74.       return Convert_Ids (System.Tasking.Self);
  75.    end Current_Task;
  76.  
  77.    -----------
  78.    -- Image --
  79.    -----------
  80.  
  81.    function Image (T : Task_Id) return String is
  82.  
  83.       function To_Address is new
  84.         Unchecked_Conversion (Task_Id, System.Address);
  85.  
  86.    begin
  87.       if T = Null_Task_Id then
  88.          return "";
  89.       else
  90.          return System.Address_Image (To_Address (T));
  91.       end if;
  92.    end Image;
  93.  
  94.    -----------------
  95.    -- Is_Callable --
  96.    -----------------
  97.  
  98.    function Is_Callable (T : Task_Id) return Boolean is
  99.    begin
  100.       if T = Null_Task_Id then
  101.          raise Program_Error;
  102.       else
  103.          return System.Tasking.Rendezvous.Callable (Convert_Ids (T));
  104.       end if;
  105.    end Is_Callable;
  106.  
  107.    -------------------
  108.    -- Is_Terminated --
  109.    -------------------
  110.  
  111.    function Is_Terminated (T : Task_Id) return Boolean is
  112.    begin
  113.       if T = Null_Task_Id then
  114.          raise Program_Error;
  115.       else
  116.          return System.Tasking.Stages.Terminated (Convert_Ids (T));
  117.       end if;
  118.    end Is_Terminated;
  119.  
  120. end Ada.Task_Identification;
  121.